import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';

export default {
  input: 'src/index.js',
  output: [
    // CommonJS 格式，适用于 Node 环境
    {
      file: 'dist/jiezhangxin-utils.cjs.js',
      format: 'cjs',
      name: 'jiezhangxinUtils'
    },
    // ES Module 格式，适用于现代浏览器和 ES6+ 环境
    {
      file: 'dist/jiezhangxin-utils.esm.js',
      format: 'es',
      name: 'jiezhangxinUtils'
    },
    // UMD 格式，适用于浏览器环境
    {
      file: 'dist/jiezhangxin-utils.umd.js',
      format: 'umd',
      name: 'jiezhangxinUtils',
      plugins: [terser()] // 压缩
    }
  ],
  plugins: [
    resolve(),
    commonjs(),
    babel({
      exclude: 'node_modules/**',
      babelHelpers: 'bundled'
    })
  ]
};
